{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 77,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "#提取到csv文件中\n",
    "import csv\n",
    "test_dict  ={}\n",
    "train_dict = {}\n",
    "for filename in [\"train.csv\", \"test.csv\"]:\n",
    "    with open(filename,'rb') as csvfile:\n",
    "        reader = csv.reader(csvfile)\n",
    "        for i,rows in enumerate(reader):\n",
    "            if i == 0:continue\n",
    "            event= str(rows[1])\n",
    "            if filename == 'train.csv':\n",
    "                train_dict[event] = rows\n",
    "            else:\n",
    "                test_dict[event] = rows\n",
    "train_test_event_set = set(train_dict)&set(test_dict)\n",
    "total_list  = []\n",
    "for tevent in list(train_test_event_set):\n",
    "    #print event ,train_dict[event]\n",
    "    total_list.append(train_dict[tevent])\n",
    "import pandas as pd\n",
    "#user\tevent\tinvited\ttimestamp\tinterested\tnot_interested\n",
    "columns_name = ['user','event','invited','timestamp','interested','not_interested']\n",
    "df = pd.DataFrame(columns=columns_name,data=total_list)\n",
    "df.to_csv('extract.csv',encoding='utf-8',index=False)   "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 78,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "#导入必要的工具包\n",
    "import pandas as pd\n",
    "import numpy as np\n",
    "from sklearn.cluster import MiniBatchKMeans\n",
    "from sklearn.model_selection import train_test_split\n",
    "from sklearn import metrics\n",
    "\n",
    "from sklearn.decomposition import PCA\n",
    "import time\n",
    "\n",
    "import matplotlib.pyplot as plt\n",
    "%matplotlib inline"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 104,
   "metadata": {},
   "outputs": [],
   "source": [
    "import datetime\n",
    "def getJoinedYearMonth(datestr):\n",
    "    dttm = datetime.datetime.strptime(datestr,\"%Y-%m-%d %H:%M:%S\")\n",
    "    return (dttm.year-2010)*12 + dttm.month\n",
    "train = pd.read_csv('extract.csv')\n",
    "#print 'traintimestamp::',train['timestamp']\n",
    "#train['timestamp']=[fe.getJoinedYearMonth(x[:-6].replace(' ','')) for x in train['timestamp']]\n",
    "train['timestamp'] =train['timestamp'].apply(lambda x : getJoinedYearMonth(x[:19]))\n",
    "y_train=train['interested']\n",
    "x_train=train.drop(['interested','not_interested'],axis=1)\n",
    "#print x_train\n",
    "#print y_train"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 105,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[  1.54564243e+09  -3.89472586e+08]\n",
      " [  1.07980604e+09  -2.76914436e+08]\n",
      " [  3.72086064e+08  -1.61759903e+09]\n",
      " ..., \n",
      " [ -2.29667467e+09  -7.97196775e+07]\n",
      " [  8.89627058e+08  -9.10059545e+08]\n",
      " [ -7.70847652e+08  -5.49935780e+08]]\n"
     ]
    }
   ],
   "source": [
    "pca = PCA(n_components=0.75)\n",
    "pca.fit(x_train)\n",
    "X_train_pca = pca.transform(x_train)\n",
    "print X_train_pca"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 106,
   "metadata": {},
   "outputs": [],
   "source": [
    "X_train_part, X_val, y_train_part, y_val = train_test_split(X_train_pca,y_train, train_size = 0.75,random_state = 0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 107,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# 一个参数点（聚类数据为K）的模型，在校验集上评价聚类算法性能\n",
    "def K_cluster_analysis(K, X_train, y_train, X_val, y_val):\n",
    "    start = time.time()\n",
    "    \n",
    "    print(\"K-means begin with clusters: {}\".format(K));\n",
    "    \n",
    "    #K-means,在训练集上训练\n",
    "    mb_kmeans = MiniBatchKMeans(n_clusters = K)\n",
    "    mb_kmeans.fit(X_train)\n",
    "    \n",
    "    # 在训练集和测试集上测试\n",
    "    #y_train_pred = mb_kmeans.fit_predict(X_train)\n",
    "    y_val_pred = mb_kmeans.predict(X_val)\n",
    "    \n",
    "    #以前两维特征打印训练数据的分类结果\n",
    "    #plt.scatter(X_train[:, 0], X_train[:, 1], c=y_pred)\n",
    "    #plt.show()\n",
    "\n",
    "    # K值的评估标准\n",
    "    #常见的方法有轮廓系数Silhouette Coefficient和Calinski-Harabasz Index\n",
    "    #这两个分数值越大则聚类效果越好\n",
    "    #CH_score = metrics.calinski_harabaz_score(X_train,mb_kmeans.predict(X_train))\n",
    "    CH_score = metrics.silhouette_score(X_train,mb_kmeans.predict(X_train))\n",
    "    \n",
    "    #也可以在校验集上评估K\n",
    "    v_score = metrics.v_measure_score(y_val, y_val_pred)\n",
    "    \n",
    "    end = time.time()\n",
    "    print(\"CH_score: {}, time elaps:{}\".format(CH_score, int(end-start)))\n",
    "    print(\"v_score: {}\".format(v_score))\n",
    "    \n",
    "    return CH_score,v_score"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 108,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "K-means begin with clusters: 10\n",
      "CH_score: 0.376193096541, time elaps:0\n",
      "v_score: 0.0152215314379\n",
      "K-means begin with clusters: 20\n",
      "CH_score: 0.349638819628, time elaps:0\n",
      "v_score: 0.0121787652101\n",
      "K-means begin with clusters: 30\n",
      "CH_score: 0.330342282727, time elaps:0\n",
      "v_score: 0.0275601121536\n",
      "K-means begin with clusters: 40\n",
      "CH_score: 0.341136785212, time elaps:0\n",
      "v_score: 0.0300832535521\n",
      "K-means begin with clusters: 50\n",
      "CH_score: 0.344353688343, time elaps:0\n",
      "v_score: 0.0369775431147\n",
      "K-means begin with clusters: 60\n",
      "CH_score: 0.351620812026, time elaps:0\n",
      "v_score: 0.0470741842953\n",
      "K-means begin with clusters: 70\n",
      "CH_score: 0.350903381912, time elaps:0\n",
      "v_score: 0.0376289807847\n",
      "K-means begin with clusters: 80\n",
      "CH_score: 0.363082425506, time elaps:0\n",
      "v_score: 0.0508174288001\n",
      "K-means begin with clusters: 90\n",
      "CH_score: 0.357156585425, time elaps:0\n",
      "v_score: 0.0544263097915\n",
      "K-means begin with clusters: 100\n",
      "CH_score: 0.365641566434, time elaps:1\n",
      "v_score: 0.0593280694258\n"
     ]
    }
   ],
   "source": [
    "# 设置超参数（聚类数目K）搜索范围\n",
    "Ks = [10, 20, 30,40,50,60,70,80,90,100]\n",
    "CH_scores = []\n",
    "v_scores = []\n",
    "for K in Ks:\n",
    "    ch,v = K_cluster_analysis(K, X_train_part, y_train_part, X_val, y_val)\n",
    "    CH_scores.append(ch)\n",
    "    v_scores.append(v)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 109,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[<matplotlib.lines.Line2D at 0xfec4978>]"
      ]
     },
     "execution_count": 109,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAX0AAAD8CAYAAACb4nSYAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4wLCBo\ndHRwOi8vbWF0cGxvdGxpYi5vcmcvpW3flQAAIABJREFUeJzt3Xl4VPXZxvHvwyaKRaRGqoACihUU\nRRtxQRCtoJi4typuaEWMQtVKWxVtq7b6qqWo9aVUtmJRFrcqr2UTd0tFQ8EFlQqoCCrixiKULb/3\nj2dSB4hkkszMmZlzf64rV5gzJzMPc03uOfmtFkJARETioV7UBYiISPYo9EVEYkShLyISIwp9EZEY\nUeiLiMSIQl9EJEYU+iIiMaLQFxGJEYW+iEiMNIi6gK3ttttuoU2bNlGXISKSV+bMmfNZCKGouvNy\nLvTbtGlDeXl51GWIiOQVM/sglfPUvCMiEiMKfRGRGFHoi4jEiEJfRCRGFPoiIjGi0BcRiRGFvohI\njBRM6C9ZAtdfD8uWRV2JiEjuKpjQX7MGbr8d/v73qCsREcldBRP6HTpA27bw5JNRVyIikrsKJvTN\noKQEZs6EdeuirkZEJDcVTOgDlJZ64D/3XNSViIjkpoIK/WOOgZ12UhOPi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QgjX\nhxBahRDa4B10z4QQzgOeBX6UOC0WrwVACOET4EMz+37i0A+Bt4jheyNhCXCEme2U+L2pfD1i+f5I\n8m3vh8nAhYlRPEcAKyubgepCk7PqyMyOBl4E3uCbduzBeLv+Q8Be+Jv9xyGELyIpMgJm1gP4eQih\n1Mza4Vf+zYG5wPkhhPVR1pctZtYZGAU0AhYDF+MXW7F8b5jZzcDZ+Ki3uUA/vJ06Fu8PM5sA9MBX\n01wO/AZ4nCreD4kPxv/FR/usBS4OIdR5W0GFvohIjKh5R0QkRhT6IiIxotAXEYkRhb6ISIwo9EVE\nYkShLyISIwp9EZEYUeiLiMTI/wNpvNkgvzumwgAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0xff12c88>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.plot(Ks, np.array(CH_scores), 'b-')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 110,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[<matplotlib.lines.Line2D at 0x10140470>]"
      ]
     },
     "execution_count": 110,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAX0AAAD8CAYAAACb4nSYAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4wLCBo\ndHRwOi8vbWF0cGxvdGxpYi5vcmcvpW3flQAAIABJREFUeJzt3XmcjfX///HHy75kp5QlhGylNInS\nhkrWsZM+oeSXbC2+fUQqUn359KGFlD4RJZQ0RkPKGmUbSdmGCTGWsu9mzMz798ccfTTf0RycmWvO\nnOf9dpubc67zPud6nuPynMt1Xee6zDmHiIiEhhxeBxARkcyj0hcRCSEqfRGREKLSFxEJISp9EZEQ\notIXEQkhKn0RkRCi0hcRCSEqfRGREJLL6wCplSxZ0l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CVPoiIiHk/wMQ9K0Ycgn0MgAA\nAABJRU5ErkJggg==\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0xe5b7dd8>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.plot(Ks, np.array(v_scores), 'g-')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.14"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
